package com.ftg.learn.bus.menu.menu_controller;

import com.ftg.learn.bus.menu.menu_pojo.menu_admin;
import com.ftg.learn.bus.menu.menu_service.menu_admin_service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api(value = "菜单表",tags = "菜单列表")
@CrossOrigin
public class menu_admin_controller {
    @Autowired
    menu_admin_service mas;

    @GetMapping("/menu/querMenu")
    @ApiOperation("查询所有菜单信息")
    public List<Map<String,Object>> querMenu(){
        return mas.querMenu();
    }

    @PostMapping("/menu/insert")
    @ApiOperation("添加菜单")
    public int insert(menu_admin ma){
        return mas.insert(ma);
    }

    @PostMapping("/menu/update")
    @ApiOperation("修改菜单信息")
    public int update(menu_admin ma){
        return mas.update(ma);
    }

    @DeleteMapping("/menu/delete/{manu_id}")
    @ApiOperation("根据菜单id删除菜单信息")
    public int delete(@ApiParam("菜单id") @PathVariable int manu_id){
        return mas.deleteByMenu_id(manu_id);
    }

    @PutMapping("/menu/findone/{manu_id}")
    @ApiOperation("根据菜单id查询菜单信息")
    public menu_admin findOne(@ApiParam("菜单id") @PathVariable int manu_id){
        return mas.findOne(manu_id);
    }

    @DeleteMapping("/menu/deletes/{menu_ids}")
    @ApiOperation("多条删除菜单")
    public int delete(@ApiParam("用户名(多条)") @PathVariable List<Integer> menu_ids){
        return mas.deletes(menu_ids);
    }
}
